package com.gitee.lougnib.hellowebim.common.mybatis.mapper;

import static com.gitee.lougnib.hellowebim.common.mybatis.mapper.ChatRoomMessageEntityDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.gitee.lougnib.hellowebim.common.mybatis.entity.ChatRoomMessageEntity;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface ChatRoomMessageMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(id, remark, messageType, chatRoomId, senderId, sendTime, status, version, messageContent, attachment);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<ChatRoomMessageEntity> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<ChatRoomMessageEntity> multipleInsertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ChatRoomMessageEntityResult")
    Optional<ChatRoomMessageEntity> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ChatRoomMessageEntityResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="message_type", property="messageType", jdbcType=JdbcType.INTEGER),
        @Result(column="chat_room_id", property="chatRoomId", jdbcType=JdbcType.BIGINT),
        @Result(column="sender_id", property="senderId", jdbcType=JdbcType.BIGINT),
        @Result(column="send_time", property="sendTime", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
        @Result(column="version", property="version", jdbcType=JdbcType.INTEGER),
        @Result(column="message_content", property="messageContent", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="attachment", property="attachment", jdbcType=JdbcType.LONGVARBINARY)
    })
    List<ChatRoomMessageEntity> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(ChatRoomMessageEntity record) {
        return MyBatis3Utils.insert(this::insert, record, chatRoomMessageEntity, c ->
            c.map(id).toProperty("id")
            .map(remark).toProperty("remark")
            .map(messageType).toProperty("messageType")
            .map(chatRoomId).toProperty("chatRoomId")
            .map(senderId).toProperty("senderId")
            .map(sendTime).toProperty("sendTime")
            .map(status).toProperty("status")
            .map(version).toProperty("version")
            .map(messageContent).toProperty("messageContent")
            .map(attachment).toProperty("attachment")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(Collection<ChatRoomMessageEntity> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, chatRoomMessageEntity, c ->
            c.map(id).toProperty("id")
            .map(remark).toProperty("remark")
            .map(messageType).toProperty("messageType")
            .map(chatRoomId).toProperty("chatRoomId")
            .map(senderId).toProperty("senderId")
            .map(sendTime).toProperty("sendTime")
            .map(status).toProperty("status")
            .map(version).toProperty("version")
            .map(messageContent).toProperty("messageContent")
            .map(attachment).toProperty("attachment")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(ChatRoomMessageEntity record) {
        return MyBatis3Utils.insert(this::insert, record, chatRoomMessageEntity, c ->
            c.map(id).toPropertyWhenPresent("id", record::getId)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
            .map(messageType).toPropertyWhenPresent("messageType", record::getMessageType)
            .map(chatRoomId).toPropertyWhenPresent("chatRoomId", record::getChatRoomId)
            .map(senderId).toPropertyWhenPresent("senderId", record::getSenderId)
            .map(sendTime).toPropertyWhenPresent("sendTime", record::getSendTime)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(version).toPropertyWhenPresent("version", record::getVersion)
            .map(messageContent).toPropertyWhenPresent("messageContent", record::getMessageContent)
            .map(attachment).toPropertyWhenPresent("attachment", record::getAttachment)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<ChatRoomMessageEntity> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<ChatRoomMessageEntity> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<ChatRoomMessageEntity> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<ChatRoomMessageEntity> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, chatRoomMessageEntity, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(ChatRoomMessageEntity record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalTo(record::getId)
                .set(remark).equalTo(record::getRemark)
                .set(messageType).equalTo(record::getMessageType)
                .set(chatRoomId).equalTo(record::getChatRoomId)
                .set(senderId).equalTo(record::getSenderId)
                .set(sendTime).equalTo(record::getSendTime)
                .set(status).equalTo(record::getStatus)
                .set(version).equalTo(record::getVersion)
                .set(messageContent).equalTo(record::getMessageContent)
                .set(attachment).equalTo(record::getAttachment);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(ChatRoomMessageEntity record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(id).equalToWhenPresent(record::getId)
                .set(remark).equalToWhenPresent(record::getRemark)
                .set(messageType).equalToWhenPresent(record::getMessageType)
                .set(chatRoomId).equalToWhenPresent(record::getChatRoomId)
                .set(senderId).equalToWhenPresent(record::getSenderId)
                .set(sendTime).equalToWhenPresent(record::getSendTime)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(version).equalToWhenPresent(record::getVersion)
                .set(messageContent).equalToWhenPresent(record::getMessageContent)
                .set(attachment).equalToWhenPresent(record::getAttachment);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(ChatRoomMessageEntity record) {
        return update(c ->
            c.set(remark).equalTo(record::getRemark)
            .set(messageType).equalTo(record::getMessageType)
            .set(chatRoomId).equalTo(record::getChatRoomId)
            .set(senderId).equalTo(record::getSenderId)
            .set(sendTime).equalTo(record::getSendTime)
            .set(status).equalTo(record::getStatus)
            .set(version).equalTo(record::getVersion)
            .set(messageContent).equalTo(record::getMessageContent)
            .set(attachment).equalTo(record::getAttachment)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(ChatRoomMessageEntity record) {
        return update(c ->
            c.set(remark).equalToWhenPresent(record::getRemark)
            .set(messageType).equalToWhenPresent(record::getMessageType)
            .set(chatRoomId).equalToWhenPresent(record::getChatRoomId)
            .set(senderId).equalToWhenPresent(record::getSenderId)
            .set(sendTime).equalToWhenPresent(record::getSendTime)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(version).equalToWhenPresent(record::getVersion)
            .set(messageContent).equalToWhenPresent(record::getMessageContent)
            .set(attachment).equalToWhenPresent(record::getAttachment)
            .where(id, isEqualTo(record::getId))
        );
    }
}